package demo3;
import java.lang.reflect.Array;
class MyArray<T> {
    //public T[] obj2 = new T[10];
    public T[] obj ;
    public MyArray() {
    }
    //反射相关 【了解】
    public MyArray(Class<T> clazz, int capacity) {
        obj = (T[]) Array.newInstance(clazz, capacity);
    }

    public void setVal(int pos,T val) {
        obj[pos] = val;
    }

    public T getPos(int pos) {
        return obj[pos];
    }
    public T[] getObj2() {
        return obj;
    }
}

public class Test {

    public static void main(String[] args) {
        MyArray<Integer> myArray = new MyArray<>(Integer.class,10);
        Integer[] tmp = myArray.getObj2();

    }

}